package practise.server;

import practise.shared.Container;

import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiMethod.HttpMethod;
import com.google.appengine.api.users.User;

@Api(name = "oauthtest", 
	scopes = { "https://www.googleapis.com/auth/userinfo.email" }
)
public class API {
	
	@ApiMethod(path = "getuser", httpMethod = HttpMethod.GET)
	public Container getLoggedInUser(User user) {
		
		Container container = new Container();
		container.loggedInUser = "not logged in";
		
		if (null != user) {
			container.loggedInUser = user.getEmail();
		}
		
		return container;
	}
}
